{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# 接続テスト\n",
    "\n",
    "(インストール手順は略)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mysql: [Warning] Using a password on the command line interface can be insecure.\n",
      "+------------+\n",
      "| CURDATE()  |\n",
      "+------------+\n",
      "| 2017-07-13 |\n",
      "+------------+\n"
     ]
    }
   ],
   "source": [
    "mysql -ujoruri -p'pass' -h 10.136.3.175 -e \"SELECT CURDATE();\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## 文字化け対策\n",
    "\n",
    "クライアント側に原因がある場合は「/etc/mysql/conf.d/client.cnf」にutf-8となる設定を入れる"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "```\n",
    "# mysql -ujoruri -p'pass' -h 10.136.3.175 -e \"(SQL)\" 2> /dev/null\n",
    "+----------+---------+------+---------+-------------------------------------+\n",
    "| id       | user_id | uid  | mailbox | subject                             |\n",
    "+----------+---------+------+---------+-------------------------------------+\n",
    "| 58507283 |    6428 |    3 | INBOX   | ????????????                        |\n",
    "| 58507288 |    6428 |    4 | INBOX   | 4MB????                             |\n",
    "| 58507285 |    6428 |    5 | INBOX   | ?=?         ※ 元々が化けている     |\n",
    "| 58507289 |    6428 |    6 | INBOX   | &#x1F363;   ※ 🍣                  |\n",
    "| 58507290 |    6428 |    7 | INBOX   | Undelivered Mail Returned to Sender |\n",
    "+----------+---------+------+---------+-------------------------------------+\n",
    "\n",
    "# vi /etc/mysql/conf.d/client.cnf\n",
    "================================================\n",
    "[client]\n",
    "port = 3306\n",
    "default-character-set = utf8\n",
    "================================================\n",
    "\n",
    "# mysql -ujoruri -p'pass' -h 10.136.3.175 -e \"(SQL)\" 2> /dev/null\n",
    "+----------+---------+------+---------+--------------------------------------+\n",
    "| id       | user_id | uid  | mailbox | subject                              |\n",
    "+----------+---------+------+---------+--------------------------------------+\n",
    "| 58507283 |    6428 |    3 | INBOX   | メール環境テスト                     |\n",
    "| 58507288 |    6428 |    4 | INBOX   | 4MBファイル                          |\n",
    "| 58507285 |    6428 |    5 | INBOX   | ?=?                                  |\n",
    "| 58507289 |    6428 |    6 | INBOX   | &#x1F363;                            |\n",
    "| 58507290 |    6428 |    7 | INBOX   | Undelivered Mail Returned to Sender  |\n",
    "+----------+---------+------+---------+--------------------------------------+\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Bash",
   "language": "bash",
   "name": "bash"
  },
  "language_info": {
   "codemirror_mode": "shell",
   "file_extension": ".sh",
   "mimetype": "text/x-sh",
   "name": "bash"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
